/**
 * problem_036.cpp
 * Copyright (C) 2011 - xrose
 */

#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;

string binConvert(const int N)
{
	string s;
	int c = N, r;
	while(c>0)
	{
		r = c%2;
		c=c/2;
		s+=(r+48);
	}
	reverse(s.begin(), s.end());
	return s;
}
int isPalin(const string str)
{
    string s = str;
    reverse(s.begin(), s.end());
    if(s==str)
    {
        return 1;
    } else
    {
        return 0;
    }
}
int isPalin(const int numb)
{
    stringstream ss;
    ss<<numb;
    return isPalin(ss.str());
}
int main (int argc, char const* argv[])
{
    int MPAL = 1000000;
	cout<<binConvert(8)<<endl;
	cout<<isPalin("1234549321")<<endl;
	cout<<isPalin(1234554321)<<endl;
	int sum = 0;
	for(int i = 0; i<MPAL; i++)
	{
	    if((isPalin(i))&&(isPalin(binConvert(i))))
	    {
	        sum+=i;
	    }
	}
	cout<<"sum = "<<sum<<endl;
	return 0;
}
